<?php
/**
 * Laed eine Ini Datei und bietet eine Objektorientierte Schnitstelle zu den Daten
 *
 */
class Kanedo_Config_Ini
{
    /**
     * Pfad zur Configdatei
     *
     * @access protected
     * @var string
     */
    protected $configFile = null;
    /**
     * Speichert die geladen section
     *
     * @access protected
     * @var string
     */
    protected $section = null;
    /**
     * Enthaelt die Config 
     *
     * @access protected
     * @var array
     */
    protected $config = null;
    
    /**
     * Konstruktor
     *
     * @param string $configFile
     */
    public function __construct($configFile)
    {
        $this->configFile = $configFile;
        $this->loadIniFile();
    }

    /**
     * Magische Methode zum Holen der Config
     *
     * @param string $name
     * @return Kanedo_Config_Ini | string
     */
    public function __get($name)
    {
        if ($this->section == null) {
            $this->section = $name;
            return $this;
        } else {
            $value = isset($this->config[$this->section][$name])?$this->config[$this->section][$name]:FALSE;
            $this->section = null;
            return $value;
        }

    }
    
    /**
     * Läd die angegebene Ini datei
     *
     */
    protected function loadIniFile()
    {
        $this->config = parse_ini_file($this->configFile, true);
    }
    
    public function getSection($section)
    {
    	return $this->config[$section];
    }

}  
?>